/* D:\ITCDEV\PRJ\ICAD\MTEXTRICHEDIT.CPP
 * Copyright (C) 1997-1999 DIMINE Co.LTD. All rights reserved.
 * 
 * $Revision: 1.1.1.1 $ $Date: 2010/03/03 02:57:12 $
 * 
 * Abstract
 * 
 * <TODO : Add Abstract here>
 * 
 */ 

// MTextRichEdit.cpp : implementation file
//

#include "stdafx.h"

#include "MTextRichEdit.h"
#include "MTextPropSheet.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// MTextRichEdit

MTextRichEdit::MTextRichEdit()
	{
	}

MTextRichEdit::~MTextRichEdit()
	{
	}


BEGIN_MESSAGE_MAP(MTextRichEdit, CRichEditCtrl)
	//{{AFX_MSG_MAP(MTextRichEdit)
	ON_WM_KEYDOWN()
	ON_WM_MOUSEMOVE()
	ON_WM_KEYUP()
	ON_WM_KILLFOCUS()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// MTextRichEdit message handlers


void MTextRichEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
	{
	CRichEditCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
	((MTextPropSheet*) GetParent())->UpdateChar();	
	}

void MTextRichEdit::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
	{	
	CRichEditCtrl::OnKeyUp(nChar, nRepCnt, nFlags);
	if (!((MTextPropSheet*) GetParent())->m_textTab.m_undo.IsWindowEnabled() && 
		(BOOL)::SendMessage(m_hWnd, EM_CANUNDO, 0, 0))
		((MTextPropSheet*) GetParent())->m_textTab.m_undo.EnableWindow(TRUE);
	}

void MTextRichEdit::OnMouseMove(UINT nFlags, CPoint point) 
	{	
	CRichEditCtrl::OnMouseMove(nFlags, point);
	if (GetFocus() == this)
		((MTextPropSheet*) GetParent())->UpdateChar();
	}

void MTextRichEdit::OnKillFocus(CWnd* pNewWnd) 
{
	((MTextPropSheet*) GetParent())->UpdateChar();
	CRichEditCtrl::OnKillFocus(pNewWnd);	
}
